//
//  ViewController.m
//  UI08_界面通信
//
//  Created by LGC on 16/3/18.
//  Copyright © 2016年 Apon. All rights reserved.
//

#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

#import "ViewController.h"
#import "SecondViewController.h"
@interface ViewController ()

@property (nonatomic, retain) UITextField * textFieldOfUser;

@property (nonatomic, retain) UIButton *nextButton;

@end



@implementation ViewController

- (void)dealloc {
    [_textFieldOfUser release];
    [_nextButton release];
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self createSubViews];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    self.navigationItem.title = @"首页";
}

- (void)createSubViews {
    self.textFieldOfUser = [[UITextField alloc]initWithFrame:CGRectMake(20, 80, 300, 40)];
    self.textFieldOfUser.borderStyle = 3;
    self.textFieldOfUser.placeholder = @"请输入用户名";
    [self.view addSubview:self.textFieldOfUser];
    [_textFieldOfUser release];
    
    self.nextButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.nextButton.frame = CGRectMake(50, 200, WIDTH / 5, HEIGHT / 10);
    self.nextButton.center = self.view.center;
    [self.nextButton setTitle:@"Next" forState:UIControlStateNormal];
    [self.view addSubview:self.nextButton];
    self.nextButton.backgroundColor  = [UIColor yellowColor];
    [self.nextButton addTarget:self action:@selector(handleAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

- (void)handleAction:(UIButton *)button {
    SecondViewController *second = [[SecondViewController alloc]init];
    // 属性赋值.
    second.contents = self.textFieldOfUser.text;
    
    [self.navigationController pushViewController:second animated:YES];
    [second release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
